/**
 * Created by QianQi on 2016/6/3.
 */
$(function(){
    var form=$('#registForm');
    $('.regEye').click(togglePwd);// 切换密码显示
    $('#regBtn').click(regFn);// 注册
    var valiObj=form.initValidator({
        rules:{
            'user':{'required':true}
            ,'tel':{
                'required':true
                ,'isPhone':true
            }
            ,'pwd':{'required':true}
        }
        ,messages:{
            'user':{'required':'必填'}
        }
    });


    function regFn(){
        if(!valiObj.validateAll()) return;
        console.log(form.serializeObject());
    }
    function togglePwd(){
        var pwdEl=form.find('[name="pwd"]');
        if(pwdEl.attr('type')=='text'){
            pwdEl.attr('type','password');
        }else{
            pwdEl.attr('type','text');
        }
    }
});